﻿<?php
	error_reporting(E_ALL^E_NOTICE);
	require_once ('./config/config.php'); 
	require_once ('./class/email.class.php'); 
	require_once ('./class/tools.class.php');
	date_default_timezone_set("PRC");
	session_start();
	if(empty($_SESSION['user'])){
		echo "<script>location='./login.php';</script>";
		exit();
	}else{
		$userRs=mysqli_fetch_array(mysqli_query($con,"select * from user where user='".$_SESSION['user']."'"));
	}
?>
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>某高校图书共享网站</title>
		<meta name="description" content="A responsive web app template with common components like profile, list, tabs, menu views. Made for Codrops exclusively.">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="stylesheet" href="./assets/output.css">
		<link rel="stylesheet" href="./assets/node_modules/tippy.js/dist/themes/light.css">
		<link rel="stylesheet" href="./layui/css/layui.css">
		<script src="./layui/js/layui.js" v="layui" e="layui"></script>
	</head>
	<body class="bg-grey-lighter font-sans antialiased">
		<!--[if lt IE 7]>
			<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
		<![endif]-->
		<div class="bg-indigo-darker text-center p-4 px-6 flex items-center">
			<div class="hidden lg:block lg:w-1/4 xl:w-1/5 pr-8">
				<font color="#ffffff"><h1>某高校图书共享网站</h1></font>
			</div>
		</div>
		<!-- Main -->
		<div class="flex">
			<!-- Content -->
			<div class="flex flex-1 flex-col md:px-6 pt-10" id="content">
				<!-- Title -->
				<div class="px-6 md:px-0 flex justify-between items-center -order-1">
					<div>
						<h2 class="font-normal"><a href="./index.php">首页</a> / <?php if($_GET['uid']){echo "<a href='./my.php'>个人中心</a> / 我的需求";}else{echo "需求大厅";}?></h2>
					</div>
					<p>欢迎您，<?php echo $_SESSION['user'];?> !</p>
				</div>
				<!-- Desktop Stats -->
				<div class="hidden px-6 md:px-0 mt-4 md:flex flex-wrap order-1 md:-order-1 md:shadow-md js-tab-pane" id="section-stats">
					<div class="p-4 px-6 w-full md:w-1/2 rounded md:rounded-r-none bg-white shadow-md md:shadow-none">
						<table class="mt-4 w-full">
							<thead class="p-2 text-sm leading-loose border-b text-indigo">
								<tr>
									<td>需求ID</td>
									<td class="text-center">需求标题</td>
									<td class="text-center">需求内容</td>
									<td class="text-center">发布时间</td>
									<td class="text-right">是/否解决</td>
								</tr>
							</thead>
							<tbody class="p-2 leading-loose text-sm">
								<?php
									if($_GET['uid']){
										$demand=mysqli_query($con,"select * from demand where uid='".$_GET['uid']."' order by demand_id asc");
									}else{
										$demand=mysqli_query($con,"select * from demand order by demand_id asc");
									}
									while($demandRs=mysqli_fetch_array($demand)){ ?>
										<tr class="border-b">
											<td class="py-2"><?php echo $demandRs['demand_id'];?></td>
											<td class="py-2 text-center"><a href="JavaScript:alert('<?php echo $demandRs['demand_name'];?>');">查看</a></td>
											<td class="py-2 text-center"><a href="JavaScript:alert('<?php echo $demandRs['demand_contant'];?>');">查看</a></td>
											<td class="py-2 text-center"><?php echo $demandRs['demand_time'];?></td>
											<td class="py-2 text-right"><?php if($demandRs['demand_state']=="0"){echo "未解决";}elseif($demandRs['demand_state']=="1"){echo "已解决";}?></td>
										</tr>
								<?php
									}
								?>
							</tbody>
						</table>
					</div>
					<div class="w-full md:w-1/2 p-4 md:pt-12 md:pl-1 mt-4 md:mt-0 lg:pt-12 lg:pl-8 rounded md:rounded-r-none bg-white shadow-md md:shadow-none">
						<div class="flex">
							<div class="w-1/2">
								<p class="text-indigo text-sm p-2">没有你想要的书？</p>
								<p class="font-medium text-sm pl-2"><a href="./demand-add.php">发布需求</a></p>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script src="./assets/bundle.js" async defer></script>
</body>
</html>
